package com.guodexian.xiaomi.controller;

import com.guodexian.xiaomi.service.CategoryService;
import com.guodexian.xiaomi.service.impl.CategoryServiceImpl;
import com.guodexian.xiaomi.util.HttpResponseUtil;
import com.guodexian.xiaomi.vo.ResultVO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 类说明：  <br>
 *
 * @author 南阳德刚<br>
 * 2024-12-31 10:39<br>
 * @since 1.0 <br>
 * 培养IT高薪技术人才的摇篮---北京学佳澳。<br>
 * 点击<a href="http://www.xuejiaao.com/images/qrcode.jpg">学佳澳教育</a>关注公共号,有惊喜(⊙o⊙)<br>
 */
@WebServlet("/category/del")
public class CategoryDelController extends HttpServlet {
    private CategoryService categoryService=new CategoryServiceImpl();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1 获取参数
        Long cid = Long.parseLong(req.getParameter("cid"));
        //2 业务
        int ret=categoryService.deleteCategory(cid);
        if(ret>0){
            HttpResponseUtil.response(resp, ResultVO.success(ret));
        }else {
            HttpResponseUtil.response(resp,ResultVO.fail("删除失败"));
        }

    }
}
